<?php


namespace app\common\lib\sms;
use AlibabaCloud\SDK\Dysmsapi\V20170525\Dysmsapi;
use Darabonba\OpenApi\Models\Config;
use AlibabaCloud\SDK\Dysmsapi\V20170525\Models\SendSmsRequest;
class AliSmsNew
{
    /**
     * 使用AK&SK初始化账号Client
     * @param string $accessKeyId
     * @param string $accessKeySecret
     * @return Dysmsapi Client
     */
    public static function createClient($accessKeyId, $accessKeySecret){
//        dump($accessKeyId);
//        exit();
        $config = new Config([
            // 您的AccessKey ID
            "accessKeyId" => $accessKeyId,
            // 您的AccessKey Secret
            "accessKeySecret" => $accessKeySecret
        ]);
        // 访问的域名
        $config->endpoint = "dysmsapi.aliyuncs.com";
        return new Dysmsapi($config);
    }

    /**
     * @param string[] $args
     * @return void
     */
    public static function main($args){
        $client = self::createClient("LTAI4G9hCXaxyVDzT1qYkmYq", "Rs27SUnFWJKH5jQAjrgefQFLUyI6QD");
        $sendSmsRequest = new SendSmsRequest([
            "signName" => "breeze网站",
            "templateCode" => "SMS_203672751",
            "templateParam" => "{\"code\":\"387895\"}",
            "phoneNumbers" => "15936233187"
        ]);
        $resp = $client->sendSms($sendSmsRequest);
        Console::log(Utils::toJSONString(Tea::merge($resp)));
    }
}
//$path = __DIR__ . \DIRECTORY_SEPARATOR . '..' . \DIRECTORY_SEPARATOR . 'vendor' . \DIRECTORY_SEPARATOR . 'autoload.php';
//if (file_exists($path)) {
//    require_once $path;
//}
